package com.nl.gen.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

/**
 * 规则配置项.
 *
 * @author breggor
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class GenerateConfig {

    public static final String DEFAULT_OUT_PATH = "src/main/java";

    public static final String DEFAULT_XML_OUT_PATH = "src/main/resources";

    /**
     * 作者.
     */
    private String author;

    /**
     * 项目包名.
     */
    private String packageName;

    /**
     * 生成类型  hibernate 或者 mybatis.
     */
    private String category;

    /**
     * 生成框架  dubbo 或者 springCloud.
     */
    private String framework;

    /**
     * 表前缀(类名不会包含表前缀).
     */
    private String tablePrefix;

    /**
     * 文件输出路径.
     */
    private String outPath;

    /**
     * xml文件输出路径.
     */
    private String xmlOutPath;

    /**
     * 模块名称.
     */
    private String moduleName;

    /**
     * 默认配置.
     *
     * @return GenerateConfig
     */
    public static GenerateConfig defaultConfig() {
        return new GenerateConfig("atinbo generator", "com.atinbo", "mybatis", "dubbo", "", DEFAULT_OUT_PATH, DEFAULT_XML_OUT_PATH, null);
    }

    /**
     * author.
     *
     * @param author author
     * @return GenerateConfig
     */
    public GenerateConfig setAuthor(final String author) {
        if (StringUtils.isNotBlank(author)) {
            this.author = author;
        }
        return this;
    }

    /**
     * setPackageName.
     *
     * @param packageName packageName
     * @return GenerateConfig
     */
    public GenerateConfig setPackageName(final String packageName) {
        if (StringUtils.isNotBlank(packageName)) {
            this.packageName = packageName;
        }
        return this;
    }

    /**
     * setCategory.
     *
     * @param category category
     * @return GenerateConfig
     */
    public GenerateConfig setCategory(final String category) {
        if (StringUtils.isNotBlank(category)) {
            this.category = category;
        }
        return this;
    }

    /**
     * setFramework.
     *
     * @param framework framework
     * @return GenerateConfig
     */
    public GenerateConfig setFramework(final String framework) {
        if (StringUtils.isNotBlank(framework)) {
            this.framework = framework;
        }
        return this;
    }

    /**
     * setTablePrefix.
     *
     * @param tablePrefix tablePrefix
     * @return GenerateConfig
     */
    public GenerateConfig setTablePrefix(final String tablePrefix) {
        if (StringUtils.isNotBlank(tablePrefix)) {
            this.tablePrefix = tablePrefix;
        }
        return this;
    }

    /**
     * setOutPath.
     *
     * @param outPath outPath
     * @return GenerateConfig
     */
    public GenerateConfig setOutPath(final String outPath) {
        if (StringUtils.isNotBlank(outPath)) {
            this.outPath = outPath;
        }
        return this;
    }

    /**
     * setModuleName.
     *
     * @param moduleName moduleName
     * @return GenerateConfig
     */
    public GenerateConfig setModuleName(final String moduleName) {
        if (StringUtils.isNotBlank(moduleName)) {
            this.moduleName = moduleName;
        }
        return this;
    }
}
